﻿Imports System.Data.OleDb

Public Class ReleaseReview
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_rate_Click(sender As Object, e As EventArgs) Handles btn_rate.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("godzillaFilms").ConnectionString)
        conn.Open()
        Dim rmsql = "DELETE FROM releaseRating WHERE Rater=@f1 AND ReleaseID=@f2"
        Dim rmcmd As New OleDbCommand(rmsql, conn)
        rmcmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        rmcmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        rmcmd.ExecuteNonQuery()
        Dim sql As String = "INSERT INTO releaseRating (Rating, ReleaseID, Rater) VALUES (@f1, @f2, @f3)"
        Dim cmd As New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@f1", Rating2.CurrentRating)
        cmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        cmd.Parameters.AddWithValue("@f3", User.Identity.Name)
        cmd.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("releaseDetail.aspx?ID=" & Request.Params("ID"))
    End Sub
End Class